<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@page language="java" pageEncoding="UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">
	<link href="../css/main.css" rel="stylesheet">
    <style type="text/css">
        .abj{
            padding-left: 24px;
        }
    </style>
</head>
<body>
			<div class="AccountManagement_c " id="AccountManagement_c">
                <h3>账户管理 
                    <div class="amcl fr">
                        <input type="text" placeholder="用户名" class="fl" name="">
                        <div class="search fl"><img src="../images/search.png"></div>
                    </div> 
                </h3>
                <div class="AM_ct text_center">
                    <div class="AM_ct_in">
                        <div class="add_btn df_btn fl" id="add_Account_btn">添加</div>
                        <div class="edit_btn df_btn fl" id="edit_Account_btn">编辑</div>
                        <div class="delete_btn df_btn fl" id="delete_Account_btn">删除</div>
                        <div class="fr df_btn ac_btn" id="ac_Account_btn">账号授权</div>
                    </div>
                </div>

                <div class="list">
                    <ul class="list_h">
                        <li class="b20"><label><input type="checkbox" name=""><span>用户名</span></label></li>
                        <li class="b20"><label>密码</label></li>
                        <li class="b20"><label>昵称</label></li>
                        <li class="b20"><label>创建时间</label></li>
                        <li class="b20"><label>操作</label></li>
                    </ul>
                    <div class="list_b_c">

                    <C:forEach items="${list}" var="u">

                        <ul class="list_b">
                            <li class="b20"><label><input type="checkbox" name=""><span>${u.acct}</span></label></li>
                            <li class="b20"><label>${u.pwd}</label></li>
                            <li class="b20"><label>${u.name}</label></li>
                            <li class="b20"><label>${fn:substring(u.crtime,0,19)}</label></li>
                            <li class="b20"><label> <a class="edit_btn df_btn fl abj"  onclick="showUserEdit(${u.id})" >编辑</a>
                                <a href="${pageContext.request.contextPath}/delUser?uid=${u.id}" class="delete_btn df_btn fl abj">删除</a></label></li>
                        </ul>
                    </C:forEach>
                    </div>
                    <div class="pull_page">
                        <div class="fl pull_page_up"><a href="${pageContext.request.contextPath}/page/AccountManagement.html?pageNum=${page.prePage}">上一页</a></div>
                            <ul>

                                 <c:choose>
                                     <c:when test="${page.pageNum<3}">
                                         <c:forEach begin="1" end="${page.pages<5?pages:5}" var="i">
                                             <li><a href="${pageContext.request.contextPath}/page/AccountManagement.html?pageNum=${i}">${i}</a></li>
                                         </c:forEach>
                                     </c:when>

                                     <c:when test="${page.pageNum>=3}">
                                         <c:forEach begin="${page.pageNum-2}" end="${page.pageNum}" var="i">
                                             <li><a href="${pageContext.request.contextPath}/page/AccountManagement.html?pageNum=${i}">${i}</a></li>
                                         </c:forEach>

                                         <c:forEach begin="${page.pageNum+1}" end="${page.pageNum+2}" var="i">
                                             <li><a href="${pageContext.request.contextPath}/page/AccountManagement.html?pageNum=${i}">${i}</a></li>
                                         </c:forEach>
                                     </c:when>
                                 </c:choose>

                            </ul>
                        <div class="fl pull_page_down"><a href="${pageContext.request.contextPath}/page/AccountManagement.html?pageNum=${page.nextPage}">下一页</a></div>
                    </div>

                    
                </div>
            </div>


            <!-- 弹窗 -->
    <!-- 添加账户 -->
    <div class="add_Account dn" id="add_Account">
        <form action="${pageContext.request.contextPath}/addUser" method="post">
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    添加账户
                    <span class="fr add_Account_close"><img src="../images/close.png"></span>
                </div>
            </div>
            <div class="user_name user_i">
                <label>用户名</label> <input type="text" placeholder="输入用户名" name="userAcct">
            </div>
            <div class="user_password user_i">
                <label>密<i>调</i>码</label> <input type="password" placeholder="输入密码" name="userPwd">
            </div>
            <button class="add_Account_ok_btn text_center" type="submit" >确<i>皮</i>定</button>
        </div>
        </form>
    </div>

    <!-- 账户编辑 -->
    <div class="add_Account dn" id="user_column">
        <form action="${pageContext.request.contextPath}/updateUser" method="post">
            <input type="hidden" name="uid" id="userid"/>
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    编辑账户
                    <span class="fr add_Account_close"><img src="../images/close.png"></span>
                </div>
            </div>
            <div class="column_now ">正在编辑 “<span id="editeuseracct"></span>”账户</div>
            <div class="user_name user_i">
                <label>用户名</label> <input type="text" placeholder="输入用户名" name="userName" id="userName">
            </div>
            <div class="user_password user_i">
                <label>密<i>调</i>码</label> <input type="password" placeholder="输入密码" name="userPwd" id="userPwd">
            </div>
            <button class="add_Account_ok_btn text_center" type="submit">确<i>皮</i>定</button>
        </div>
        </form>
    </div>

    <!-- 删除账户 -->
    <div class="add_Account dn" id="delete_Account">
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    删除账户
                    <span class="fr add_Account_close"><img src="../images/close.png"></span>
                </div>
            </div>
            <div class="delete_text">确定删除“ <span>jiaopwuchu</span> ”账户吗？</div>
            <div class="add_Account_ok_btn text_center" id="delete_Account_ok_btn">确<i>皮</i>定</div>
        </div>
    </div>

    <!-- 账户授权 -->
    <div class="add_Account dn" id="ac_Account">
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    账户栏目授权
                    <span class="fr add_Account_close"><img src="../images/close.png"></span>
                </div>
            </div>
            <ul>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
            </ul>
            <div class="add_Account_ok_btn text_center" id="ac_Account_ok_btn">保<i>呀</i>存</div>
        </div>
    </div>
    
</body>
<script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="../js/main.js"></script>
<script type="text/javascript">


    function showUserEdit(id){
        $.ajax({
            type:"get",
            url:"${pageContext.request.contextPath}/getUser?uid="+id,
            success:function (rs){
                console.log(rs);
                var user=JSON.parse(rs);
                console.log(user);
                $("#editeuseracct").html(user.acct);
                $("#userName").val(user.name);
                $("#userPwd").val(user.pwd);
                $("#userid").val(user.id);
            }
        });




        $("#user_column").show();
    }


</script>
</html>